home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / driver 2.2 / drvrincludes.h < prev    next >
Text File  |  1993-10-23  |  4KB  |  134 lines

  1. /* drvrincludes.h 2.2 - part of Pete Resnick's driver package */
  2.  
  3. #ifndef __DRVRINCLUDES__
  4. #define __DRVRINCLUDES__
  5.  
  6.  
  7. /*
  8.  *    This file customizes driver.c for your environment. It adjusts for
  9.  *    differences between MPW C 3.x, THINK C 4.0.x, 5.0.x, and 6.0.x as
  10.  *    well as allow you to change the resource ID for the THINK C patch.
  11.  *    You should only need to change these next five lines. If you are
  12.  *    using MPW, uncomment the first line and change the version number
  13.  *    to the major release being used, and comment out the THINK_PROC and
  14.  *    MACHEADERS lines. If you are using THINK C, change the THINK_PROC
  15.  *    definition to the resource ID you are using for ThinkProc if you are
  16.  *    using something different than 128 and comment or uncomment the other
  17.  *    three lines depending on your environment.
  18.  */
  19.  
  20. /* #define MPW                3    /* Using MPW, change the version number to suit */
  21. #define THINK_PROC        128        /* Resource ID for THINK C patch */
  22. #define MACHEADERS                /* Using THINK C MacHeaders */
  23. /* #define THINK_4_SYS7            /* Using THINK C 4 and Sys 7 headers */
  24. /* #define SYSEQU_H                /* Using SysEqu.h instead of LoMem.h */
  25.  
  26. /*
  27.  *    You shouldn't need to change anything below here!!!!!
  28.  */
  29.  
  30.  
  31. #ifndef THINK_C
  32. #    ifndef SYSEQU_H
  33. #        define SYSEQU_H
  34. #    endif /* SYSEQU_H */
  35. #    undef MACHEADERS
  36. #endif    /* THINK_C */
  37.  
  38. #ifndef MACHEADERS
  39. #    if(!defined(THINK_C) || (THINK_C >= 5) || defined(THINK_4_SYS7))
  40. #        include <Devices.h>
  41. #        include <Errors.h>
  42. #        include <Memory.h>
  43. #        include <Resources.h>
  44. #        include <ToolUtils.h>
  45. #        include <Traps.h>
  46. #        ifdef SYSEQU_H
  47. #            include <SysEqu.h>
  48. #        else
  49. #            include <LoMem.h>
  50. #        endif
  51. #    else
  52. #        include <DeviceMgr.h>
  53. #        include <FileMgr.h>
  54. #        include <MacTypes.h>
  55. #        include <MemoryMgr.h>
  56. #        include <ResourceMgr.h>
  57. #        include <SysErr.h>
  58. #        define PBOpenSync(x) PBOpen(x, false)
  59. #        define PBCloseSync(x) PBClose(x, false)
  60. #        define PBControlSync(x) PBControl(x, false)
  61. #    endif
  62. #endif
  63.  
  64. #ifndef nil
  65. #    define nil ((void *) 0L)
  66. #endif
  67.  
  68. #ifdef SYSEQU_H
  69. #    define UTABLEBASE    (*(DCtlHandle **)UTableBase)
  70. #    define UNITNTRYCNT    (*(short *)UnitNtryCnt)
  71. #else
  72. #    define UTABLEBASE    UTableBase
  73. #    define UNITNTRYCNT    UnitNtryCnt
  74. #endif
  75.  
  76. #ifndef dOpened
  77. #    define dOpened        0x0020
  78. #endif /* dOpened */
  79. #ifndef dRAMBased
  80. #    define dRAMBased    0x0040
  81. #endif /* dRAMBased */
  82. #ifndef offsetof
  83. #    define offsetof(field,type) ((unsigned long)&(((type *)0L)->field))
  84. #endif
  85.  
  86. /* This structure used in ThinkChangeCode and ThinkCleanup */
  87. typedef struct {
  88.     short inst12[2];
  89.     union {
  90.         short inst34[2];
  91.         ResType theType;
  92.     } p1;
  93.     union {
  94.         ResType theType;
  95.         short inst34[2];
  96.     } p2;
  97.     union {
  98.         short inst56[2];
  99.         Ptr codePtr;
  100.     } p3;
  101.     short inst7;
  102. } CodeChunk;
  103.  
  104. /* This structure used in ThinkAddRsrcs, ThinkRmvRsrcs, and THINK_PROC */
  105. typedef struct {
  106.     Handle rsrc;
  107.     ResType typ;
  108.     short id;
  109. } RsrcRec;
  110.  
  111. /*
  112.  *    DrvrInstall and DrvrRemove are documented in Technical Note 108.
  113.  *    DisableInterrupts and ResetStatusRegister are used internally in GrowUTable.
  114.  *    They are written as inline code for portability. THINK C 5 or greater and
  115.  *    MPW 3 or greater can use the "#pragma parameter" directive.
  116.  */
  117. #if((defined(THINK_C) && THINK_C >= 5) || (defined(MPW) && MPW >= 3))
  118. #pragma parameter __D0 DrvrInstall(__A0, __D0)
  119. OSErr DrvrInstall(Handle drvrHandle, short refNum) = {0x2050,0xA03D};
  120. #pragma parameter __D0 DrvrRemove(__D0)
  121. OSErr DrvrRemove(short refNum) = 0xA03E;
  122. short DisableInterrupts(void) = {0x40C0,0x46FC,0x2600};
  123. #pragma parameter ResetStatusRegister(__D0)
  124. void ResetStatusRegister(short oldSR) = 0x46C0;
  125. #else
  126. pascal OSErr DrvrInstall(Handle drvrHandle, short refNum)
  127.     = {0x301F,0x205F,0x2050,0xA03D,0x3E80};
  128. pascal OSErr DrvrRemove(short refNum)
  129.     = {0x301F,0xA03E,0x3E80};
  130. pascal short DisableInterrupts(void) = {0x40D7,0x46FC,0x2600};
  131. pascal void ResetStatusRegister(short oldSR) = {0x46DF};
  132. #endif
  133.  
  134. #endif /* __DRVRINCLUDES__ */